package com.ruoyi.dash.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dash.domain.TbMemberEnterprise;
import com.ruoyi.dash.service.ITbMemberEnterpriseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 成员企业信息Controller
 * 
 * @author ruoyi
 * @date 2025-10-22
 */
@RestController
@RequestMapping("/dash/enterprise")
public class TbMemberEnterpriseController extends BaseController
{
    @Autowired
    private ITbMemberEnterpriseService tbMemberEnterpriseService;

    /**
     * 查询成员企业信息列表
     */
    @PreAuthorize("@ss.hasPermi('dash:enterprise:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbMemberEnterprise tbMemberEnterprise)
    {
        startPage();
        List<TbMemberEnterprise> list = tbMemberEnterpriseService.selectTbMemberEnterpriseList(tbMemberEnterprise);
        return getDataTable(list);
    }

    /**
     * 导出成员企业信息列表
     */
    @PreAuthorize("@ss.hasPermi('dash:enterprise:export')")
    @Log(title = "成员企业信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbMemberEnterprise tbMemberEnterprise)
    {
        List<TbMemberEnterprise> list = tbMemberEnterpriseService.selectTbMemberEnterpriseList(tbMemberEnterprise);
        ExcelUtil<TbMemberEnterprise> util = new ExcelUtil<TbMemberEnterprise>(TbMemberEnterprise.class);
        util.exportExcel(response, list, "成员企业信息数据");
    }

    /**
     * 获取成员企业信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('dash:enterprise:query')")
    @GetMapping(value = "/{enterpriseId}")
    public AjaxResult getInfo(@PathVariable("enterpriseId") String enterpriseId)
    {
        return success(tbMemberEnterpriseService.selectTbMemberEnterpriseByEnterpriseId(enterpriseId));
    }

    /**
     * 新增成员企业信息
     */
    @PreAuthorize("@ss.hasPermi('dash:enterprise:add')")
    @Log(title = "成员企业信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbMemberEnterprise tbMemberEnterprise)
    {
        return toAjax(tbMemberEnterpriseService.insertTbMemberEnterprise(tbMemberEnterprise));
    }

    /**
     * 修改成员企业信息
     */
    @PreAuthorize("@ss.hasPermi('dash:enterprise:edit')")
    @Log(title = "成员企业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbMemberEnterprise tbMemberEnterprise)
    {
        return toAjax(tbMemberEnterpriseService.updateTbMemberEnterprise(tbMemberEnterprise));
    }

    /**
     * 删除成员企业信息
     */
    @PreAuthorize("@ss.hasPermi('dash:enterprise:remove')")
    @Log(title = "成员企业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{enterpriseIds}")
    public AjaxResult remove(@PathVariable String[] enterpriseIds)
    {
        return toAjax(tbMemberEnterpriseService.deleteTbMemberEnterpriseByEnterpriseIds(enterpriseIds));
    }
}
